<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>title</title>
<link rel="stylesheet"
	href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script type="text/javascript"
	src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="/OffTheRecord/js/jquery.validate.js"></script>

<script type="text/javascript">
	$(document)
			.ready(
					function() {
						<c:set value="${adminVo.adminId }" var="admin"/>
						<c:set value="${userVo.userId }" var="user"/>
						var admin = "<c:out value="${admin}"/>";
						var user = "<c:out value="${user}"/>";
						if (user.length == 0 && admin.length == 0) {
							alert("로그인 하세요");
							location.href = "/OffTheRecord/index/index.jsp";
						}
						$('#company_name')
								.change(
										function() {
											$
													.ajax({
														type : "post",
														url : "getCompanyInfoByCompanyName.action",
														data : "companyName="
																+ $(
																		'#company_name')
																		.val(),
														dataType : "json",

														success : function(data) {
															$('#industry_name')
																	.val(
																			data.clist[0].industryVo.industryName);
															$('#region_name')
																	.val(
																			data.clist[0].regionVo.regionName);
														}
													});
										});//change

						$('#reviewForm').validate({
							rules : {
								companyName : {
									required : true
								},
								companyReviewSalary : {
									required : true,
									number : true
								},
								industryName : {
									required : true
								},
								regionName : {
									required : true
								},
								professionName : {
									required : true
								},
								companyReview : {
									required : true
								},
								companyMerit : {
									required : true
								},
								companyDemerit : {
									required : true
								}

							},
							messages : {
								companyName : {
									required : "회사명을 입력하세요."
								},
								companyReviewSalary : {
									required : "연봉을 입력하세요.",
									number : "숫자만 입력하세요"
								},
								industryName : {
									required : "산업명을 입력하세요."
								},
								regionName : {
									required : "지역명을 입력하세요."
								},
								professionName : {
									required : "직종명을 입력하세요."
								},
								companyReview : {
									required : "리뷰를 입력하세요."
								},
								companyMerit : {
									required : "장점을 입력하세요."
								},
								companyDemerit : {
									required : "단점을 입력하세요."
								}
							},
						});

					});

	function validateForm() {
		$('#scoreChanceSpan').html("");
		$('#scoreCultureSpan').html("");
		$('#scoreWelfareSpan').html("");
		$('#scoreHolidaySpan').html("");
		$('#scoreExecutiveSpan').html("");
		$('#scoreOverdueSpan').html("");
		var radios;
		var formValid;

		for (var j = 0; j < 6; j++) {
			if (j == 0) {
				radios = document.getElementsByName("scoreChance");
				formValid = false;
			} else if (j == 1) {
				radios = document.getElementsByName("scoreWelfare");
				formValid = false;
			} else if (j == 2) {
				radios = document.getElementsByName("scoreCulture");
				formValid = false;
			} else if (j == 3) {
				radios = document.getElementsByName("scoreHoliday");
				formValid = false;
			} else if (j == 4) {
				radios = document.getElementsByName("scoreExecutive");
				formValid = false;
			} else if (j == 5) {
				radios = document.getElementsByName("scoreOverdue");
				formValid = false;
			}

			var i = 0;
			while (!formValid && i < radios.length) {
				if (radios[i].checked)
					formValid = true;
				i++;
			}

			if (!formValid
					&& radios == document.getElementsByName("scoreChance"))
				$('#scoreChanceSpan').html("승진 기회 및 가능성을 입력해 주세요.");
			if (!formValid
					&& radios == document.getElementsByName("scoreWelfare"))
				$('#scoreWelfareSpan').html("복지를 입력해 주세요.");
			if (!formValid
					&& radios == document.getElementsByName("scoreCulture"))
				$('#scoreCultureSpan').html("사내문화를 입력해 주세요.");
			if (!formValid
					&& radios == document.getElementsByName("scoreHoliday"))
				$('#scoreHolidaySpan').html("휴가 자율성을 입력해 주세요.");
			if (!formValid
					&& radios == document.getElementsByName("scoreExecutive"))
				$('#scoreExecutiveSpan').html("경영진을 입력해 주세요.");
			if (!formValid
					&& radios == document.getElementsByName("scoreOverdue"))
				$('#scoreOverdueSpan').html("초과근무를 입력해 주세요.");

		}
		if (formValid == false)
			return formValid;

		alert("리뷰 등록이 완료되었습니다!");
		$('#reviewForm').submit();
	}
	function reportCompany() {
		if ($('#company_name').val() == "") {
			alert("회사 이름을 입력해 주세요!");
			return document.reviewForm.companyName.focus();
		}

		var i = confirm("회사 등록을 신청하시겠습니까?");
		if (i) {
			$.ajax({
				type : "post",
				url : "/OffTheRecord/reportCompanyRegister.action",
				data : "companyName=" + $('#company_name').val(),
				dataType : "json",

				success : function(data) {
					alert(data.message);
				}
			}); //ajax
		}
	}
</script>
</head>
<body>
	<c:if
		test="${sessionScope.adminVo!=null || sessionScope.userVo != null }">
		<c:import url="../common/top.jsp"></c:import>
		<div class="container" style="margin: 60px;"></div>

		<div class="container">
			<div class="row">
				<div class="col-xs-1 col-xs-1 col-xs-1 col-xs-1"></div>

				<div class="register-form col-xs-10 col-sm-10 col-md-10 col-lg-10">

					<div class="col-xs-9 col-sm-8 col-md-8 col-lg-8"
						style="border: 1px solid lightgray; border-radius: 5px; padding: 10px;">
						<h1 align="center">
							<b>리뷰 작성하기</b>
							<!--  <span class="glyphicon glyphicon-pencil"> -->
						</h1>
						<hr size="1" color="lightgray">

						<div class="btnbtn">
							<button class="btn btn-danger" onclick="reportCompany()">기업
								신청하기</button>
							<br> -찾으시는 기업이 없으시면 기업 신청하기 버튼으로 기업을 신청해주세요.
						</div>
						<!-- form -->
						<form class="form-horizontal" role="form" id="reviewForm"
							method="post" action="/OffTheRecord/writeCompanyReview.action"
							name="reviewForm">
							<!-- 기업명 -->
							<div class="form-group">
								<label class="control-label col-lg-2" for="company_name">기업명:</label>

								<div class="col-lg-10">

									<input type="text" class="form-control" list="companyName"
										name="companyName" id="company_name">
									<datalist id="companyName"> <c:forEach
										items="${listMap.companyList }" var="clist">
										<option id="clist" value="${clist.companyName}">
									</c:forEach> </datalist>
								</div>
							</div>


							<!-- 기업명 -->

							<!-- 산업 -->
							<div class="form-group">
								<label class="control-label col-lg-2" for="company_name">산업:</label>
								<div class="col-lg-10">
									<input type="text" class="form-control" list="industryName"
										name="industryName" id="industry_name" disabled>
									<datalist id="industryName"> <c:forEach
										items="${listMap.industryList }" var="ilist">
										<option value="${ilist.industryName}">
									</c:forEach> </datalist>
								</div>
							</div>
							<!-- 산업 -->

							<!-- 지역 -->
							<div class="form-group">
								<label class="control-label col-lg-2" for="company_name">지역:</label>
								<div class="col-lg-10">
									<input type="text" class="form-control" list="regionName"
										name="regionName" id="region_name" onkeyup="autoRegion()"
										disabled>
									<datalist id="regionName"> <c:forEach
										items="${listMap.regionList }" var="rlist">
										<option id="rlist" value="${rlist.regionName}">
									</c:forEach> </datalist>
								</div>
							</div>
							<!-- 지역 -->

							<!-- 직종 -->
							<div class="form-group">
								<label class="control-label col-lg-2" for="company_name">직종:</label>
								<div class="col-lg-10">
									<input type="text" class="form-control" list="professionName"
										name="professionName" id="profession_name">
									<datalist id="professionName"> <c:forEach
										items="${listMap.professionList }" var="plist">
										<option value="${plist.professionName}">
									</c:forEach> </datalist>
								</div>
							</div>
							<!-- 직종 -->

							<!-- 연봉 -->
							<div class="form-group">
								<label class="control-label col-lg-2" for="Salary">연봉:</label>
								<div class="col-lg-10">
									<input type="text" class="form-control" id="company_salary"
										name="companyReviewSalary"
										placeholder="연봉을 숫자로 입력해주세요. 단위는 '만' 단위 입니다.">
								</div>
							</div>
							<!-- 연봉 -->

							<!-- score -->
							<div class="score col-lg-12">
								<hr>
								<!-- 라디오 -->
								<div class="form-group">
									<label class="control-label col-lg-4" for="company_name">승진
										기회 및 가능성 : </label>

									<div class="btn-group col-lg-8" id="score_chance"
										data-toggle="buttons">
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreChance" value="1" id="score_chance"
											autocomplete="off" checked>매우나쁨</label> <label
											class="btn btn-primary btn-xs"><input type="radio"
											name="scoreChance" value="2" id="score_chance"
											autocomplete="off">나쁨</label> <label
											class="btn btn-primary btn-xs"><input type="radio"
											name="scoreChance" value="3" id="score_chance"
											autocomplete="off">보통</label> <label
											class="btn btn-primary btn-xs"><input type="radio"
											name="scoreChance" value="4" id="score_chance"
											autocomplete="off">좋음</label> <label
											class="btn btn-primary btn-xs"><input type="radio"
											name="scoreChance" value="5" id="score_chance"
											autocomplete="off">매우좋음</label>
									</div>
									<span id="scoreChanceSpan"></span>
								</div>
								<!-- 라디오 -->

								<!-- 라디오 -->
								<div class="form-group">
									<label class="control-label col-lg-4" for="company_name">복지
										및 급여 : </label>

									<div class="btn-group col-lg-8" data-toggle="buttons">
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreWelfare" value="1" id="score_welfare">매우나쁨</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreWelfare" value="2" id="score_welfare">나쁨</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreWelfare" value="3" id="score_welfare">보통</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreWelfare" value="4" id="score_welfare">좋음</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreWelfare" value="5" id="score_welfare">매우좋음</label>
									</div>
									<span id="scoreWelfareSpan"></span>
								</div>
								<!-- 라디오 -->

								<!-- 라디오 -->
								<div class="form-group">
									<label class="control-label col-lg-4" for="company_name">사내
										문화 : </label>

									<div class="btn-group col-lg-8" data-toggle="buttons">
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreCulture" value="1" id="score_culture">매우나쁨</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreCulture" value="2" id="score_culture">나쁨</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreCulture" value="3" id="score_culture">보통</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreCulture" value="4" id="score_culture">좋음</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreCulture" value="5" id="score_culture">매우좋음</label>
									</div>
									<span id="scoreCultureSpan"></span>
								</div>
								<!-- 라디오 -->

								<!-- 라디오 -->
								<div class="form-group">
									<label class="control-label col-lg-4" for="company_name">휴가
										자율성 : </label>

									<div class="btn-group col-lg-8" data-toggle="buttons">
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreHoliday" value="1" id="score_holiday">매우나쁨</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreHoliday" value="2" id="score_holiday">나쁨</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreHoliday" value="3" id="score_holiday">보통</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreHoliday" value="4" id="score_holiday">좋음</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreHoliday" value="5" id="score_holiday">매우좋음</label>
									</div>
									<span id="scoreHolidaySpan"></span>
								</div>
								<!-- 라디오 -->

								<!-- 라디오 -->
								<div class="form-group">
									<label class="control-label col-lg-4" for="company_name">경영진
										: </label>

									<div class="btn-group col-lg-8" data-toggle="buttons">
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreExecutive" value="1"
											id="score_executive">매우나쁨</label> <label
											class="btn btn-primary btn-xs"><input type="radio"
											name="scoreExecutive" value="2" id="score_executive">나쁨</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreExecutive" value="3"
											id="score_executive">보통</label> <label
											class="btn btn-primary btn-xs"><input type="radio"
											name="scoreExecutive" value="4" id="score_executive">좋음</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreExecutive" value="5"
											id="score_executive">매우좋음</label>
									</div>
									<span id="scoreExecutiveSpan"></span>
								</div>
								<!-- 라디오 -->

								<!-- 라디오 -->
								<div class="form-group">
									<label class="control-label col-lg-4" for="company_name">초과근무
										: </label>

									<div class="btn-group col-lg-8" data-toggle="buttons">
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreOverdue" value="1" id="score_overdue">매우나쁨</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreOverdue" value="2" id="score_overdue">나쁨</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreOverdue" value="3" id="score_overdue">보통</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreOverdue" value="4" id="score_overdue">좋음</label>
										<label class="btn btn-primary btn-xs"><input
											type="radio" name="scoreOverdue" value="5" id="score_overdue">매우좋음</label>
									</div>
									<span id="scoreOverdueSpan"></span>
								</div>
								<!-- 라디오 -->
							</div>
							<!-- End score -->

							<!-- 리뷰 -->
							<div class="form-group">
								<label class="control-label col-lg-2" for="review">리뷰:</label>
								<div class="col-lg-10">
									<textarea class="form-control" rows="10" name="companyReview"
										id="company_review" placeholder="리뷰를 여기에 작성해주세요."></textarea>
								</div>
							</div>
							<!-- 리뷰 -->

							<!-- 장점 -->
							<div class="form-group">
								<label for="pros" class="col-lg-2 control-label">장점:</label>
								<div class="col-lg-10">
									<textarea class="form-control" rows="5" name="companyMerit"
										id="company_merit" placeholder="장점 여기에 작성해주세요."></textarea>
								</div>
							</div>
							<!-- 리뷰 -->

							<!-- 단점 -->
							<div class="form-group">
								<label for="cons" class="col-lg-2 control-label">단점:</label>
								<div class="col-lg-10">
									<textarea class="form-control" rows="5" name="companyDemerit"
										id="company_demerit" placeholder="단점 여기에 작성해주세요."></textarea>
								</div>
							</div>
							<!-- 단점 -->
							<!-- 
      <label class="">- 이 기업을 추천하시겠습니까?</label>
      <label class="radio-inline">
          <input type="radio" name="optradio">예
        </label>
        <label class="radio-inline">
          <input type="radio" name="optradio">아니요
        </label>
        <br> -->


							<!-- 버튼 -->
							<button type="button" class="btn btn-default"
								onclick="location.href='/OffTheRecord/index/index.jsp'">홈으로</button>
							<button type="button" class="btn btn-success"
								style="float: right;" onclick="validateForm()">작성하기</button>
							<!-- 버튼 -->
						</form>
						<!-- form -->

					</div>
					<!-- 리뷰 작성 -->
					<div class="col-xs-1 col-xs-1 col-xs-1 col-xs-1"></div>

					<!-- ################################################################################################## -->
					<!-- 오른쪽 -->
					<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"
						style="border: 1px solid lightgray; padding: 10px;">

						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"
							style="border: 1px solid lightgray; padding: 10px;">
							<dl>
								<dt>리뷰등록 정책</dt>
								<p>
								<dd>기업 리뷰의 투명성을 유지하고 악성 정보에 따른 고의적 기업 평점 하락을 방지하기 위해, 작성된
									모든 정보는 OFF the Record의 자체적인 검토 과정을 거쳐 등록됩니다.</dd>
							</dl>
						</div>

						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"
							style="border: 1px solid lightgray; border-radius: 10px; padding: 10px;">
							<dl>
								<dt>리뷰 등록 거부목록</dt>
								<dd>•욕설</dd>
								<dd>•특정개인의 폄훼, 비방(특정 인물을 지칭할 수 있는 이름, 직책, 직급 등을 직접적으로 표기)</dd>
								<dd>•공격적인 언어</dd>
								<dd>•고용계약서나 비밀유지 서약에반하는 내용</dd>
								<dd>•기업 리뷰나 면접 정보와</dd>
								<dd>•정보의 질을 떨어뜨리는 비속어 및 은어</dd>
								<p>
								<p>이상의 내용에 해당 사항이 없는 기업 리뷰 및 면접 정보는 작성된 상태 그대로 등록됩니다.
								<p>
								<p>자세한 정보는 OFF the Record 커뮤니티 가이드라인을 참고하세요.
							</dl>
						</div>

						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"
							style="border: 1px solid lightgray; border-radius: 10px; padding: 10px;">
							<dl>
								<bt>기업 리뷰를 써야 하는 이유</bt>
								<dd>"어디로 갈지 결정해야 할 마지막 순간에 Off the Record의 기업리뷰가 큰 도움이 되었다.
									덕분에나에게 잘 맞는 회사를 선택할 수 있었다."</dd>

								<font size="2" color="gray">- 당신의 리뷰로 더 나은 삶을 살게 될 미래의 유저</font>
								<p>
								<p>
								<dd>
							</dl>


						</div>
						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"
							style="border: 1px solid lightgray; border-radius: 10px; padding: 10px;">

						</div>

					</div>
					<!-- 오른쪽 -->
				</div>

				<div class="col-xs-1 col-xs-1 col-xs-1 col-xs-1"></div>
			</div>
			<!-- row -->
		</div>
		<!-- container -->
		<script
			src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
		<script
			src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
	</c:if>
</body>
</html>